﻿# -*-coding:  UTF-8
# @Time    :  2021/9/13 22:25
# @Author  :  Cooper
# @FileName:  rundamo.py
# @Software:  PyCharm
import sys
import maindemo as u1
import second as u2
from PyQt5 import  QtGui, QtWidgets
from PyQt5.Qt import *



class SecondWindow(QMainWindow):
    def __init__(self):
        super(SecondWindow, self).__init__()
        super().__init__()
        self.ui = u2.Ui_Form()
        self.ui.setupUi(self)

    def slot2(self):
        win.show()
        win2.close()


class MainWindow(QMainWindow):
    def __init__(self, parent=None):
        super(MainWindow, self).__init__(parent)  # 使用父类的初始化方法来初始化子类，也就是说，子类继承了父类的所有属性和方法。父类属性自然会用父类方法来进行初始化。
        icon = QtGui.QIcon()
        icon.addPixmap(QtGui.QPixmap('apple.ico'), QtGui.QIcon.Normal, QtGui.QIcon.Off)
        MainWindow.setWindowIcon(self, icon)
        self.ui = u1.Ui_Form()
        self.ui.setupUi(self)

    def slot1(self):
        print('进入函数')
        if self.ui.lineEdit.text() == "mingri":
            print('账号存在')
            if self.ui.lineEdit_2.text() == '123456':
                print('密码正确')
                if self.ui.radioButton.isChecked():
                    win2.show()
                    win.close()
                else:
                    # self.ui.lineEdit.clear()
                    self.ui.lineEdit_2.clear()
                    win2.show()
                    win.close()
            else:
                from PyQt5.QtWidgets import QMessageBox
                # 使用information（)方法弹出消息提示框
                QMessageBox.information(QtWidgets.QMainWindow(), '登录消息', '密码错误 请重新输入', QMessageBox.Ok)
                # self.ui.lineEdit_2.setText('密码错误请重新输入')
        else:
            print('进入else')
            self.ui.lineEdit.setText('账号错误请重新输入')


if __name__ == "__main__":
    app = QApplication(sys.argv)
    win = MainWindow()
    win.show()
    win2 = SecondWindow()
    sys.exit(app.exec_())
